<?php
// +----------------------------------------------------------------------
// | 07FLYSAAS [基于ThinkPHP5.0开发]
// +----------------------------------------------------------------------
// | Copyright (c) 2025-2035 http://www.07fly.xyz
// +----------------------------------------------------------------------
// | Professional because of focus  Persevering because of happiness
// +----------------------------------------------------------------------
// | Author: 开发人生 <goodkfrs@qq.com>
// +----------------------------------------------------------------------

namespace app\plat\controller;

/**
 * 系统消息
 */
class TenMsg extends PlatBase
{
    /**
     * 消息列表
     */
    public function show()
    {
        $type_list = $this->logicTenMsgType->getTenMsgTypeList('', '', '', false);
        $this->assign('type_list', $type_list);
        return $this->fetch('show');
    }

    /**
     * 消息列表
     */
    public function show_my()
    {
        if (IS_POST) {
            $this->param['deal_user_id']= TEN_USER_ID;
            $where = $this->logicTenMsg->getWhere($this->param);
            $orderby = $this->logicTenMsg->getOrderby($this->param);
            $list = $this->logicTenMsg->getTenMsgList($where, '*', $orderby);
            return $list;
        }
        $this->comm_data();
        return $this->fetch('show_my');
    }

    /**
     * 消息列表
     */
    public function show_json()
    {
        $where = $this->logicTenMsg->getWhere($this->param);
        $orderby = $this->logicTenMsg->getOrderby($this->param);
        $list = $this->logicTenMsg->getTenMsgList($where, true, $orderby);
        return $list;
    }

    /**
     * 营销活动添加
     * @return mixed|string
     */
    public function add()
    {
        IS_POST && $this->jump($this->logicTenMsg->tenMsgAdd($this->param));
        return $this->fetch('add');
    }

    /**
     * 编辑
     * @return mixed|string
     */
    public function edit()
    {
        IS_POST && $this->jump($this->logicTenMsg->tenMsgEdit($this->param));
        $info = $this->logicTenMsg->getTenMsgInfo(['id' => $this->param['id']]);
        $this->assign('info', $info);
        return $this->fetch('edit');
    }

    /**
     * 消息删除
     */
    public function del()
    {
        $this->jump($this->logicTenMsg->tenMsgDel($this->param));
    }

    /**
     * 发送消息
     */
    public function send_msg()
    {
        $this->jump($this->logicTenMsg->tenMsgSend($this->param));
    }

    /**
     * 启用
     */
    public function set_visible()
    {
        $this->jump($this->logicPlatBase->setField('TenMsg', $this->param));
    }

    /**
     * 标记处理
     */
    public function set_deal()
    {
        $this->jump($this->logicTenMsg->tenMsgSetDeal($this->param));
    }

    /**
     * 公共数据
     * @return void
     * @author: 开发人生 goodkfrs@qq.com
     * @Time: 2022/12/13 16:06
     */
    public function comm_data()
    {
        $type_list = $this->logicTenMsgType->getTenMsgTypeList('', '', '', false);
        $this->assign('type_list', $type_list);
    }

}
